<template>
  <div class="fixedLayout" :class="[collapse ? 'collapse-true' : 'collapse-false']">
    <router-view />
  </div>
</template>

<script>
export default {
  name: 'Layout',
  data() {
    return {
      isFixedLayout: false,
      collapse: false
    };
  },
  mounted() {
    window.addEventListener('message', this.receiveMsg);
  },
  methods: {
    receiveMsg(info) {
      let { data } = info
      switch (data.type) {
        // 切换路由
        case 'changeRoute':
          this.changeRoute(data.params)
          break;
        // 切换padding
        case 'isCollapse':
          this.collapse = data.params.collapse
          break;
        default:
          break;
      }
    },
    changeRoute(data) {
      const { name } = data;
      this.$router.push({ name });
    }
  },
};
</script>

<style lang="less" scoped>
.fixedLayout {
  box-sizing: border-box;
  // padding-left: 230px;
  // padding-top: 170px;
  width: 100vw;
  height: 100vh;
  // 和el-menu同样的动画效果 ，
  // 使用动画后，切换src时，会有动画效果，体验度不知道好不好
  // transition: padding 0.3s ease-in-out;

  padding-right: 16px;
  padding-bottom: 30px;

  &.collapse-true {
    padding-left: 76px;
    padding-top: 150px;
  }

  &.collapse-false {
    padding-left: 256px;
    padding-top: 150px;
  }

  .content {
    height: 100%;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 12px;
    overflow: hidden;
  }

}
</style>
